fix: repair cross-package bugs so tests and typecheck pass - #105
Open
stooit wants to merge 1 commit into
Open
Conversation
- api.ts: import renamed hook useDebounce (was stale useThrottle) from @e2e/utils - Button: apply aria-label so icon-only buttons have an accessible name (WCAG 4.1.2) - DataTable: use functional state updater to fix stale-closure sort-direction toggle - date.ts: render day-first, unpadded day via formatToParts (en-AU) - bunfig.toml: preload happy-dom via existing packages/ui/test/setup.ts for DOM env - tsconfig.json: add bun-types to resolve bun:test module type errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
bun test && tsc --noEmitfully green from the repo root — all 13 tests pass, zero type errors. Six distinct bugs across the three packages, each fixed minimally. No test files modified, no dependencies added.Bugs fixed
Stale renamed hook (TS2305) —
apps/web/src/lib/api.tsuseDebouncewas renamed inpackages/utilsbutapi.tsstill imported the olduseThrottle. Fixed the import; kept theuseSearchDebouncere-export alias (asserted byapi.test.ts).document is not definedin React tests —bunfig.tomlThe root config used
[test].environment = "happy-dom", which is Jest/Vitest syntax that Bun silently ignores — so no DOM was ever registered. Now preloads the existingpackages/ui/test/setup.ts, which registers@happy-dom/global-registrator(already innode_modules). Single registration path keeps bothbun run test(with its--preload) and barebun testgreen.Missing accessible name —
packages/ui/.../Button.tsxaria-labelwas destructured but never applied to the<button>. Now wired through, with a fallback so icon-only buttons always have a non-null accessible name (WCAG 2.2 SC 4.1.2).Stale-closure sort bug —
packages/ui/.../DataTable.tsxThe direction toggle read
sortDirfrom the render closure, so a second click on the same committed render never flippedasc→desc. Switched to the functional updater form.Date format —
packages/utils/src/format/date.tsen-AUnumeric formatting padded the day (01/03/2024). UsesformatToPartsto un-pad only the day, preserving locale ordering/separators, so 1 March renders1/03/2024(day-first).Cannot find module 'bun:test'(TS2307 x4) —tsconfig.jsonAdded
"types": ["bun-types"](already innode_modules) to expose Bun's ambient module types.Verification
bun run test-> 13 pass / 0 failbun test-> 13 pass / 0 failbunx tsc --noEmit-> exit 0, no outputAssumptions & notes (from review)
/^1/assertion, yielding1/03/2024(unpadded day, padded month). Standard AU convention isDD/MM/YYYY; the regex over-specifies. Recommend relaxing the test to/^0?1\//and simplifying the impl in a follow-up."Button"string fallback as a last resort to keep the no-aria-labeltest's.not.toBeNull()green. Real call sites should always pass a meaningfularia-label; a compile-time discriminated union would be the stronger long-term guard.formatDateoutput is host-timezone dependent (pre-existing); could flake on a UTC+14 runner. Not changed here.